#include "Comm.hpp"

int main()
{
    //1. 获取key
    key_t key = GetKey();
    // std::cout << key << std::endl;

    //2. 创建shm
    int shmid = CreatShm(key, shmStandardSize, ServerFlag);

    //3.attach到内存中
    char* addr = (char*)ShmAttach(shmid);
    memset(addr, 0, shmStandardSize);
    
    //读写操作
    Sync sy;
    sy.Write();
    for (int i = 'a'; i <= 'z'; i++)
    {
        addr[i - 'a'] = i;
       sy.Signal();
       sleep(1);
    }

    //4.detach
    ShmDetach(addr);

    //5.删除共享内存
    DestroyShm(shmid);

    return 0;
}